#include <cppunit/config/SourcePrefix.h>

#include "TestPKBStorage.h"
#include "PKB.h"
#include "QueryExpressionParser.h"
#include <iostream>
#include <string>


void PKBStorageTest::setUp(){
}

void PKBStorageTest::tearDown(){
}

void PKBStorageTest::testGetLineIndexForPatternAssign(){
	//create a new PKB
	PKB* myPKB = new PKB();
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);


	// Currently assumes the following SIMPLE source code:
	// Procedure MyProc {
	//1.	x = 2;
	//2.	y = x;
	//3.	while x {
	//4.		x = x - 1;
	//5.		y = y + x;
	//6.		while y {
	//7.			z = y - 1;
	//			}
	//		}
	//8.	y = 5;
	// }
	//PKB pkb;
	//Type::Index::Proc procIndex = myPKB->insertProc("MyProc");
	Type::Index::Proc procIndex = 1;
	Type::Index::Var xIndex = myPKB->insertVar("x");
	Type::Index::Var yIndex = myPKB->insertVar("y");
	Type::Index::Var zIndex = myPKB->insertVar("z");
	//build AST
	TreeNode* procNode = myPKB->createTreeNode(AST_PROCEDURE, procIndex);
	TreeNode* procStmtListNode = myPKB->createTreeNode(AST_STMTLST);
	TreeNode* assign1Node = myPKB->createTreeNode(AST_ASSIGN,1);
	TreeNode* varRef1Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* con2Node1 = myPKB->createTreeNode(AST_CONST, 2);
	
	TreeNode* assign2Node = myPKB->createTreeNode(AST_ASSIGN, 2);
	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* varX2Node = myPKB->createTreeNode(AST_VAR, xIndex);

	TreeNode* while1Node = myPKB->createTreeNode(AST_WHILE, 3);
	TreeNode* varRefWNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* whileStmtListNode = myPKB->createTreeNode(AST_STMTLST);
	TreeNode* assign3Node = myPKB->createTreeNode(AST_ASSIGN,4);
	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* minus3Node = myPKB->createTreeNode(AST_MINUS);
	TreeNode* varX3Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* con1Node3 = myPKB->createTreeNode(AST_CONST, 1);

	TreeNode* assign4Node = myPKB->createTreeNode(AST_ASSIGN,5);
	TreeNode* varRef4Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* plus4Node = myPKB->createTreeNode(AST_PLUS);
	TreeNode* varY4Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* varX4Node = myPKB->createTreeNode(AST_VAR, xIndex);

	TreeNode* while2Node = myPKB->createTreeNode(AST_WHILE, 6);
	TreeNode* varRefW2Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* while2StmtListNode = myPKB->createTreeNode(AST_STMTLST);

	TreeNode* assign5Node = myPKB->createTreeNode(AST_ASSIGN,7);
	TreeNode* varRef5Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* minus5Node = myPKB->createTreeNode(AST_MINUS);
	TreeNode* varY5Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* con1Node5 = myPKB->createTreeNode(AST_CONST, 1);

	TreeNode* assign6Node = myPKB->createTreeNode(AST_ASSIGN, 8);
	TreeNode* varRef6Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* con5Node6 = myPKB->createTreeNode(AST_CONST, 5);

	//link nodes
	myPKB->linkNodes(procNode,procStmtListNode);
	myPKB->linkNodes(procStmtListNode,assign1Node);
	myPKB->linkNodes(procStmtListNode,assign2Node);
	myPKB->linkNodes(procStmtListNode,while1Node);
	myPKB->linkNodes(procStmtListNode,assign6Node);

	myPKB->linkNodes(assign1Node,varRef1Node);
	myPKB->linkNodes(assign1Node,con2Node1);
	
	myPKB->linkNodes(assign2Node,varRef2Node);
	myPKB->linkNodes(assign2Node,varX2Node);

	myPKB->linkNodes(assign6Node, varRef6Node);
	myPKB->linkNodes(assign6Node, con5Node6);

	myPKB->linkNodes(while1Node, varRefWNode);
	myPKB->linkNodes(while1Node, whileStmtListNode);

	myPKB->linkNodes(whileStmtListNode, assign3Node);
	myPKB->linkNodes(assign3Node, varRef3Node);
	myPKB->linkNodes(assign3Node, minus3Node);
	myPKB->linkNodes(minus3Node, varX3Node);
	myPKB->linkNodes(minus3Node, con1Node3);

	myPKB->linkNodes(whileStmtListNode, assign4Node);
	myPKB->linkNodes(assign4Node, varRef4Node);
	myPKB->linkNodes(assign4Node, plus4Node);
	myPKB->linkNodes(plus4Node, varY4Node);
	myPKB->linkNodes(plus4Node, varX4Node);

	myPKB->linkNodes(whileStmtListNode, while2Node);
	myPKB->linkNodes(while2Node, varRefW2Node);
	myPKB->linkNodes(while2Node, while2StmtListNode);
	myPKB->linkNodes(while2StmtListNode,assign5Node);
	myPKB->linkNodes(assign5Node, varRef5Node);
	myPKB->linkNodes(assign5Node, minus5Node);
	myPKB->linkNodes(minus5Node, varY5Node);
	myPKB->linkNodes(minus5Node, con1Node5);
	

	//myPKB->insertLine(1,1,1);
	//myPKB->insertLine(2,1,2);
	//myPKB->insertLine(3,1,3);
	//myPKB->insertLine(4,1,4);
	//myPKB->insertLine(5,1,5);
	//myPKB->insertLine(6,1,6);
	//myPKB->insertLine(7,1,7);
	//myPKB->insertLine(8,1,8);

	//myPKB->insertLineEntity(1, 1, 1, ASSIGN);
	//myPKB->insertLineEntity(2, 1, 2, ASSIGN);
	//myPKB->insertLineEntity(3, 1, 3, WHILE);
	//myPKB->insertLineEntity(4, 1, 4, ASSIGN);
	//myPKB->insertLineEntity(5, 1, 5, ASSIGN);
	//myPKB->insertLineEntity(6, 1, 6, WHILE);
	//myPKB->insertLineEntity(7, 1, 7, ASSIGN);
	//myPKB->insertLineEntity(8, 1, 8, ASSIGN);

	myPKB->insertLineEntity(1, Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertLineEntity(2, Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertLineEntity(3, Type::Entity::WHILE_LINE_ENTITY);
	myPKB->insertLineEntity(4, Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertLineEntity(5, Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertLineEntity(6, Type::Entity::WHILE_LINE_ENTITY);
	myPKB->insertLineEntity(7, Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertLineEntity(8, Type::Entity::ASSIGNMENT_LINE_ENTITY);

	//myPKB->insertNode(1,procIndex,1,assign1Node);
	//myPKB->insertNode(2,procIndex,2,assign2Node);
	//myPKB->insertNode(3,procIndex,3,while1Node);
	//myPKB->insertNode(4,procIndex,4,assign3Node);
	//myPKB->insertNode(5,procIndex,5,assign4Node);
	//myPKB->insertNode(6,procIndex,6,while2Node);
	//myPKB->insertNode(7,procIndex,7,assign5Node);
	//myPKB->insertNode(8,procIndex,8,assign6Node);

	myPKB->insertNode(1,assign1Node);
	myPKB->insertNode(2,assign2Node);
	myPKB->insertNode(3,while1Node);
	myPKB->insertNode(4,assign3Node);
	myPKB->insertNode(5,assign4Node);
	myPKB->insertNode(6,while2Node);
	myPKB->insertNode(7,assign5Node);
	myPKB->insertNode(8,assign6Node);

	cout << "COME HERE" << endl;
	//a(y,5)
	std::string expr = "5";
	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,yIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,(int)listOfMatchedLine.size());

	//a(y,"x+x")
	std::string expr2 = "x+x";
	TreeNode* subTreeRoot2 = myExpressionParser->convertExpressionToTree(expr2);
	Type::List::Line listOfMatchedLine2 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,yIndex,subTreeRoot2,true);
	CPPUNIT_ASSERT_EQUAL(0,(int)listOfMatchedLine2.size());

	//a(y,_)
	Type::List::Line listOfMatchedLine3 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,yIndex,NULL,true);
	CPPUNIT_ASSERT_EQUAL(3,(int)listOfMatchedLine3.size());

	//a ("b", "_")
	Type::List::Line listOfMatchedLine4 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,-1,NULL,true);
	CPPUNIT_ASSERT_EQUAL(0,(int)listOfMatchedLine4.size());

	//a ("_", "y-1")
	std::string expr5 = "y-1";
	TreeNode* subTreeRoot5 = myExpressionParser->convertExpressionToTree(expr5);
	Type::List::Line listOfMatchedLine5 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,subTreeRoot5,true);
	CPPUNIT_ASSERT_EQUAL(1,(int)listOfMatchedLine5.size());

	//a ("_", "y")
	std::string expr6 = "y";
	TreeNode* subTreeRoot6 = myExpressionParser->convertExpressionToTree(expr6);
	Type::List::Line listOfMatchedLine6 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,subTreeRoot6,false);
	CPPUNIT_ASSERT_EQUAL(0,(int)listOfMatchedLine6.size());

	//a ("_", "_")
	Type::List::Line listOfMatchedLine7 = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,NULL,true);
	CPPUNIT_ASSERT_EQUAL(6,(int)listOfMatchedLine7.size());

	//w ("y","_")
	Type::List::Line listOfMatchedLine8 = myPKB->getLineIndexForPattern(PATTERN_WHILE,yIndex,NULL,true);
	CPPUNIT_ASSERT_EQUAL(1,(int)listOfMatchedLine8.size());

	//myPKB->~PKB();
}


void PKBStorageTest::testGetLineIndexForPatternWithAssignOneVar(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x=x"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x";

	// build part of AST: "x=x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExpreNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();
}
void PKBStorageTest::testGetLineIndexForPatternAssignWithNoVarRef(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x=x"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x";
	
	// build part of AST: "x=x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExpreNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);
	
	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();
}
void PKBStorageTest::testGetLineIndexForPatternAssignWithNoVarRefNoExpre(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x=x"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x";

	// build part of AST: "x=x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExpreNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,NULL,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();
}

void PKBStorageTest::testGetLineIndexForPatternWithNoMatch(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x = x"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x";

	// build part of AST: "x=x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExpreNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_IF,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(true,listOfMatchedLine.empty());
	//myPKB->~PKB();
}
void PKBStorageTest::testGetLineIndexForPatternWithAssignConstant(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x = 3"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "3";
	
	// build part of AST: "x=3"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreNode = myPKB->createTreeNode(AST_CONST,3);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExpreNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternWithAssignShortExp(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x = x+3"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x+3";
	

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	//build the AST for "x=x+3"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExprePlusNode = myPKB->createTreeNode(AST_PLUS);
	TreeNode* varExpreVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* varExpreConsNode = myPKB->createTreeNode(AST_CONST,3);
	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,varExprePlusNode);
	myPKB->linkNodes(varExprePlusNode,varExpreVarNode);
	myPKB->linkNodes(varExprePlusNode,varExpreConsNode);

	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternWithAssignLongExp(){
	//create a new PKB
	PKB* myPKB = new PKB();
	//create test subtree "x = x*(y-z)"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "x*(y-z)";

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	Type::Index::Var yIndex = myPKB->insertVar("y");
	Type::Index::Var zIndex = myPKB->insertVar("z");
	//build the AST for "x=x*(y-z)"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,expreTimesNode);
	myPKB->linkNodes(expreTimesNode,expreXVarNode);
	myPKB->linkNodes(expreTimesNode,expreMinusNode);
	myPKB->linkNodes(expreMinusNode,expreYVarNode);
	myPKB->linkNodes(expreMinusNode,expreZVarNode);

	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternWithWhile(){
	PKB* myPKB = new PKB();

	//set subTreeNode
	TreeNode* subTreeRoot = NULL;

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");

	//build the AST for "while x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_WHILE);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* stmtListNode = myPKB->createTreeNode(AST_STMTLST);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,stmtListNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestWhile");

	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,WHILE);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::WHILE_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_WHILE,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(false,listOfMatchedLine.empty());
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternWhileWithNoVarRef(){
	PKB* myPKB = new PKB();

	//set subTreeNode
	TreeNode* subTreeRoot = NULL;

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");

	//build the AST for "while x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_WHILE);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* stmtListNode = myPKB->createTreeNode(AST_STMTLST);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode, stmtListNode);
	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestWhile");

	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,WHILE);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::WHILE_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_WHILE,NULL,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(false,listOfMatchedLine.empty());
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternWithIf(){
	PKB* myPKB = new PKB();

	//set subTreeNode
	TreeNode* subTreeRoot = NULL;

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");

	//build the AST for "if x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_IF);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* thenNode = myPKB->createTreeNode(AST_STMTLST);
	TreeNode* elseNode = myPKB->createTreeNode(AST_STMTLST);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,thenNode);
	myPKB->linkNodes(patternNode,elseNode);

	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestIf");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,IF);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::IF_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_IF,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}
void PKBStorageTest::testGetLineIndexForPatternIfWithNoVarRef(){
	PKB* myPKB = new PKB();

	//set subTreeNode
	TreeNode* subTreeRoot = NULL;

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");

	//build the AST for "if x"
	TreeNode* patternNode = myPKB->createTreeNode(AST_IF);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* thenNode = myPKB->createTreeNode(AST_STMTLST);
	TreeNode* elseNode = myPKB->createTreeNode(AST_STMTLST);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,thenNode);
	myPKB->linkNodes(patternNode,elseNode);

	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestIf");
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,IF);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::IF_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_IF,NULL,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	//myPKB->~PKB();	
}

//many and partial
void PKBStorageTest::testGetLineIndexForPatternWithAssignLongExpMany(){
	//create a new PKB
		PKB* myPKB = new PKB();
	//create test subtree "x = x*(y-z)"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "y-z";


	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	Type::Index::Var yIndex = myPKB->insertVar("y");
	Type::Index::Var zIndex = myPKB->insertVar("z");
	//build the AST for "x=x*(y-z)"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,expreTimesNode);
	myPKB->linkNodes(expreTimesNode,expreXVarNode);
	myPKB->linkNodes(expreTimesNode,expreMinusNode);
	myPKB->linkNodes(expreMinusNode,expreYVarNode);
	myPKB->linkNodes(expreMinusNode,expreZVarNode);

	//build the AST for "x=y-z"
	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(pattern2Node,varRef2Node);
	myPKB->linkNodes(pattern2Node,expreMinus2Node);
	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);

	//build the AST for "z=(y-z)+x"
	TreeNode* pattern3Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreYVar3Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreXVar3Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreMinus3Node = myPKB->createTreeNode(AST_MINUS);
	TreeNode* exprePlus3Node = myPKB->createTreeNode(AST_PLUS);

	myPKB->linkNodes(pattern3Node,varRef3Node);
	myPKB->linkNodes(pattern3Node,exprePlus3Node);
	myPKB->linkNodes(exprePlus3Node,expreMinus3Node);
	myPKB->linkNodes(exprePlus3Node,expreXVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreYVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreZVar3Node);

	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//x = x*(y-z)
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	//x = y-z
	//myPKB->insertLine(2,procIndex,2);
	//myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
	//myPKB->insertNode(2,procIndex,2,pattern2Node);
	myPKB->insertLineEntity(2,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(2,pattern2Node);

	//z = (y-z)+x
	//myPKB->insertLine(3,procIndex,3);
	//myPKB->insertLineEntity(3,procIndex,3,ASSIGN);
	//myPKB->insertNode(3,procIndex,3,pattern3Node);
	myPKB->insertLineEntity(3,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(3,pattern3Node);

	/*Type::List::Line realListOfMatchedLine;
	realListOfMatchedLine.push_back(1);
	realListOfMatchedLine.push_back(2);*/

	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(2,(int)listOfMatchedLine.size());
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	CPPUNIT_ASSERT_EQUAL(2,listOfMatchedLine.at(1));
	//myPKB->~PKB();
}
void PKBStorageTest::testGetLineIndexForPatternAssignLongExpManyWithNoVarRef(){
	//create a new PKB
		PKB* myPKB = new PKB();
	//create test subtree "x = x*(y-z)"
	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
	std::string expr = "y-z";
	

	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	Type::Index::Var yIndex = myPKB->insertVar("y");
	Type::Index::Var zIndex = myPKB->insertVar("z");
	//build the AST for "x=x*(y-z)"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,expreTimesNode);
	myPKB->linkNodes(expreTimesNode,expreXVarNode);
	myPKB->linkNodes(expreTimesNode,expreMinusNode);
	myPKB->linkNodes(expreMinusNode,expreYVarNode);
	myPKB->linkNodes(expreMinusNode,expreZVarNode);

	//build the AST for "x=y-z"
	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(pattern2Node,varRef2Node);
	myPKB->linkNodes(pattern2Node,expreMinus2Node);
	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);

	//build the AST for "z=(y-z)+x"
	TreeNode* pattern3Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreYVar3Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreXVar3Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreMinus3Node = myPKB->createTreeNode(AST_MINUS);
	TreeNode* exprePlus3Node = myPKB->createTreeNode(AST_PLUS);

	myPKB->linkNodes(pattern3Node,varRef3Node);
	myPKB->linkNodes(pattern3Node,exprePlus3Node);
	myPKB->linkNodes(exprePlus3Node,expreMinus3Node);
	myPKB->linkNodes(exprePlus3Node,expreXVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreYVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreZVar3Node);


	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//x = x*(y-z)
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);
	
	//x = y-z
	//myPKB->insertLine(2,procIndex,2);
	//myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
	//myPKB->insertNode(2,procIndex,2,pattern2Node);
	myPKB->insertLineEntity(2,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(2,pattern2Node);

	//z = (y-z)+x
	//myPKB->insertLine(3,procIndex,3);
	//myPKB->insertLineEntity(3,procIndex,3,ASSIGN);
	//myPKB->insertNode(3,procIndex,3,pattern3Node);
	myPKB->insertLineEntity(3,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(3,pattern3Node);

	/*Type::List::Line realListOfMatchedLine;
	realListOfMatchedLine.push_back(1);
	realListOfMatchedLine.push_back(2);*/
	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,NULL,subTreeRoot,true);
	CPPUNIT_ASSERT_EQUAL(3,(int)listOfMatchedLine.size());
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	CPPUNIT_ASSERT_EQUAL(2,listOfMatchedLine.at(1));
	CPPUNIT_ASSERT_EQUAL(3,listOfMatchedLine.at(2));

	//myPKB->~PKB();
}
void PKBStorageTest::testGetLineIndexForPatternAssignLongExpManyWithNoExpre(){
	//create a new PKB
		PKB* myPKB = new PKB();
	
	//insert into varTable
	Type::Index::Var xIndex = myPKB->insertVar("x");
	Type::Index::Var yIndex = myPKB->insertVar("y");
	Type::Index::Var zIndex = myPKB->insertVar("z");
	//build the AST for "x=x*(y-z)"
	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(patternNode,varRefNode);
	myPKB->linkNodes(patternNode,expreTimesNode);
	myPKB->linkNodes(expreTimesNode,expreXVarNode);
	myPKB->linkNodes(expreTimesNode,expreMinusNode);
	myPKB->linkNodes(expreMinusNode,expreYVarNode);
	myPKB->linkNodes(expreMinusNode,expreZVarNode);

	//build the AST for "x=y-z"
	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);

	myPKB->linkNodes(pattern2Node,varRef2Node);
	myPKB->linkNodes(pattern2Node,expreMinus2Node);
	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);

	//build the AST for "z=(y-z)+x"
	TreeNode* pattern3Node = myPKB->createTreeNode(AST_ASSIGN);
	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreYVar3Node = myPKB->createTreeNode(AST_VAR, yIndex);
	TreeNode* expreZVar3Node = myPKB->createTreeNode(AST_VAR, zIndex);
	TreeNode* expreXVar3Node = myPKB->createTreeNode(AST_VAR, xIndex);
	TreeNode* expreMinus3Node = myPKB->createTreeNode(AST_MINUS);
	TreeNode* exprePlus3Node = myPKB->createTreeNode(AST_PLUS);

	myPKB->linkNodes(pattern3Node,varRef3Node);
	myPKB->linkNodes(pattern3Node,exprePlus3Node);
	myPKB->linkNodes(exprePlus3Node,expreMinus3Node);
	myPKB->linkNodes(exprePlus3Node,expreXVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreYVar3Node);
	myPKB->linkNodes(expreMinus3Node,expreZVar3Node);


	//insert to proc table, constantTable, lineTable, entity table and node table
	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
	//x = x*(y-z)
	//myPKB->insertLine(1,procIndex,1);
	//myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
	//myPKB->insertNode(1,procIndex,1,patternNode);
	myPKB->insertLineEntity(1,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(1,patternNode);

	//x = y-z
	//myPKB->insertLine(2,procIndex,2);
	//myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
	//myPKB->insertNode(2,procIndex,2,pattern2Node);
	myPKB->insertLineEntity(2,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(2,pattern2Node);

	//z = (y-z)+x
	//myPKB->insertLine(3,procIndex,3);
	//myPKB->insertLineEntity(3,procIndex,3,ASSIGN);
	//myPKB->insertNode(3,procIndex,3,pattern3Node);
	myPKB->insertLineEntity(3,Type::Entity::ASSIGNMENT_LINE_ENTITY);
	myPKB->insertNode(3,pattern3Node);

	/*Type::List::Line realListOfMatchedLine;
	realListOfMatchedLine.push_back(1);
	realListOfMatchedLine.push_back(2);*/

	Type::List::Line listOfMatchedLine = myPKB->getLineIndexForPattern(PATTERN_ASSIGN,xIndex,NULL,true);
	CPPUNIT_ASSERT_EQUAL(2,(int)listOfMatchedLine.size());
	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedLine.at(0));
	CPPUNIT_ASSERT_EQUAL(2,listOfMatchedLine.at(1));

	//myPKB->~PKB();
}

/******************Stmt******************************/
//void PKBStorageTest::testGetStmtIndexForPatternWithAssignOneVar(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x=x"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x";
//	
//	// build part of AST: "x=x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExpreNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();
//}
//void PKBStorageTest::testGetStmtIndexForPatternAssignWithNoVarRef(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x=x"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x";
//	
//	// build part of AST: "x=x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExpreNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,NULL,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();
//}
//void PKBStorageTest::testGetStmtIndexForPatternAssignWithNoVarRefNoExpre(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x=x"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x";
//	
//	// build part of AST: "x=x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExpreNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,NULL,NULL,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();
//}
//
//void PKBStorageTest::testGetStmtIndexForPatternWithNoMatch(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x = x"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x";
//	
//	// build part of AST: "x=x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExpreNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_IF,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(true,listOfMatchedStmt.empty());
//	//myPKB->~PKB();
//}
//void PKBStorageTest::testGetStmtIndexForPatternWithAssignConstant(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x = 3"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "3";
//	
//	// build part of AST: "x=3"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreNode = myPKB->createTreeNode(AST_CONST,3);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExpreNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex, PATTERN_ASSIGN,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternWithAssignShortExp(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x = x+3"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x+3";
//	
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	//build the AST for "x=x+3"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExprePlusNode = myPKB->createTreeNode(AST_PLUS);
//	TreeNode* varExpreVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* varExpreConsNode = myPKB->createTreeNode(AST_CONST,3);
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,varExprePlusNode);
//	myPKB->linkNodes(varExprePlusNode,varExpreVarNode);
//	myPKB->linkNodes(varExprePlusNode,varExpreConsNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternWithAssignLongExp(){
//	//create a new PKB
//	PKB* myPKB = new PKB();
//	//create test subtree "x = x*(y-z)"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "x*(y-z)";
//	
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	Type::Index::Var yIndex = myPKB->insertVar("y");
//	Type::Index::Var zIndex = myPKB->insertVar("z");
//	//build the AST for "x=x*(y-z)"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
//	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,expreTimesNode);
//	myPKB->linkNodes(expreTimesNode,expreXVarNode);
//	myPKB->linkNodes(expreTimesNode,expreMinusNode);
//	myPKB->linkNodes(expreMinusNode,expreYVarNode);
//	myPKB->linkNodes(expreMinusNode,expreZVarNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternWithWhile(){
//	PKB* myPKB = new PKB();
//
//	//set subTreeNode
//	TreeNode* subTreeRoot = NULL;
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//
//	//build the AST for "while x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_WHILE);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestWhile");
//
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,WHILE);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_WHILE,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(false,listOfMatchedStmt.empty());
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternWhileWithNoVarRef(){
//	PKB* myPKB = new PKB();
//
//	//set subTreeNode
//	TreeNode* subTreeRoot = NULL;
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//
//	//build the AST for "while x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_WHILE);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestWhile");
//
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,WHILE);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_WHILE,NULL,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(false,listOfMatchedStmt.empty());
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternWithIf(){
//	PKB* myPKB = new PKB();
//
//	//set subTreeNode
//	TreeNode* subTreeRoot = NULL;
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//
//	//build the AST for "if x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_IF);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestIf");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,IF);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_IF,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//void PKBStorageTest::testGetStmtIndexForPatternIfWithNoVarRef(){
//	PKB* myPKB = new PKB();
//
//	//set subTreeNode
//	TreeNode* subTreeRoot = NULL;
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//
//	//build the AST for "if x"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_IF);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestIf");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,IF);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_IF,NULL,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();	
//}
//
////many and partial
//void PKBStorageTest::testGetStmtIndexForPatternWithAssignLongExpMany(){
//	//create a new PKB
//		PKB* myPKB = new PKB();
//	//create test subtree "x = x*(y-z)"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "y-z";
//
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	Type::Index::Var yIndex = myPKB->insertVar("y");
//	Type::Index::Var zIndex = myPKB->insertVar("z");
//	//build the AST for "x=x*(y-z)"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
//	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,expreTimesNode);
//	myPKB->linkNodes(expreTimesNode,expreXVarNode);
//	myPKB->linkNodes(expreTimesNode,expreMinusNode);
//	myPKB->linkNodes(expreMinusNode,expreYVarNode);
//	myPKB->linkNodes(expreMinusNode,expreZVarNode);
//
//	//build the AST for "x=y-z"
//	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(pattern2Node,varRef2Node);
//	myPKB->linkNodes(pattern2Node,expreMinus2Node);
//	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
//	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	myPKB->insertLine(2,procIndex,2);
//	myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
//	myPKB->insertNode(2,procIndex,2,pattern2Node);
//	
//	/*Type::List::Line realListOfMatchedLine;
//	realListOfMatchedLine.push_back(1);
//	realListOfMatchedLine.push_back(2);*/
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,xIndex,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	CPPUNIT_ASSERT_EQUAL(2,listOfMatchedStmt.at(1));
//	//myPKB->~PKB();
//}
//void PKBStorageTest::testGetStmtIndexForPatternAssignLongExpManyWithNoVarRef(){
//	//create a new PKB
//		PKB* myPKB = new PKB();
//	//create test subtree "x = x*(y-z)"
//	QueryExpressionParser* myExpressionParser = new QueryExpressionParser(myPKB);
//	std::string expr = "y-z";
//	
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	Type::Index::Var yIndex = myPKB->insertVar("y");
//	Type::Index::Var zIndex = myPKB->insertVar("z");
//	//build the AST for "x=x*(y-z)"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
//	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,expreTimesNode);
//	myPKB->linkNodes(expreTimesNode,expreXVarNode);
//	myPKB->linkNodes(expreTimesNode,expreMinusNode);
//	myPKB->linkNodes(expreMinusNode,expreYVarNode);
//	myPKB->linkNodes(expreMinusNode,expreZVarNode);
//
//	//build the AST for "x=y-z"
//	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(pattern2Node,varRef2Node);
//	myPKB->linkNodes(pattern2Node,expreMinus2Node);
//	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
//	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);
//
//	//build the AST for "z=(y-z)+x"
//	TreeNode* pattern3Node = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreYVar3Node = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVar3Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreXVar3Node = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreMinus3Node = myPKB->createTreeNode(AST_MINUS);
//	TreeNode* exprePlus3Node = myPKB->createTreeNode(AST_PLUS);
//
//	myPKB->linkNodes(pattern3Node,varRef3Node);
//	myPKB->linkNodes(pattern3Node,exprePlus3Node);
//	myPKB->linkNodes(exprePlus3Node,expreMinus3Node);
//	myPKB->linkNodes(exprePlus3Node,expreXVarNode);
//	myPKB->linkNodes(expreMinus3Node,expreYVarNode);
//	myPKB->linkNodes(expreMinus3Node,expreZVarNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	Type::Index::Proc procIndex2 = myPKB->insertProc("TestAssign2");
//	//x = x*(y-z)
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	//x = y-z
//	myPKB->insertLine(2,procIndex,2);
//	myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
//	myPKB->insertNode(2,procIndex,2,pattern2Node);
//	//z = (y-z)+x
//	myPKB->insertLine(3,procIndex2,1);
//	myPKB->insertLineEntity(3,procIndex2,1,ASSIGN);
//	myPKB->insertNode(3,procIndex2,1,pattern3Node);
//	
//	/*Type::List::Line realListOfMatchedLine;
//	realListOfMatchedLine.push_back(1);
//	realListOfMatchedLine.push_back(2);*/
//	TreeNode* subTreeRoot = myExpressionParser->convertExpressionToTree(expr);
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,NULL,subTreeRoot,true);
//	CPPUNIT_ASSERT_EQUAL(2,(int)listOfMatchedStmt.size());
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	//myPKB->~PKB();
//}
//void PKBStorageTest::testGetStmtIndexForPatternAssignLongExpManyWithNoExpre(){
//	//create a new PKB
//		PKB* myPKB = new PKB();
//
//	//insert into varTable
//	Type::Index::Var xIndex = myPKB->insertVar("x");
//	Type::Index::Var yIndex = myPKB->insertVar("y");
//	Type::Index::Var zIndex = myPKB->insertVar("z");
//	//build the AST for "x=x*(y-z)"
//	TreeNode* patternNode = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRefNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreTimesNode = myPKB->createTreeNode(AST_TIMES);
//	TreeNode* expreXVarNode = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVarNode = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVarNode = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinusNode = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(patternNode,varRefNode);
//	myPKB->linkNodes(patternNode,expreTimesNode);
//	myPKB->linkNodes(expreTimesNode,expreXVarNode);
//	myPKB->linkNodes(expreTimesNode,expreMinusNode);
//	myPKB->linkNodes(expreMinusNode,expreYVarNode);
//	myPKB->linkNodes(expreMinusNode,expreZVarNode);
//
//	//build the AST for "x=y-z"
//	TreeNode* pattern2Node = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRef2Node = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreYVar2Node = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVar2Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreMinus2Node = myPKB->createTreeNode(AST_MINUS);
//
//	myPKB->linkNodes(pattern2Node,varRef2Node);
//	myPKB->linkNodes(pattern2Node,expreMinus2Node);
//	myPKB->linkNodes(expreMinus2Node,expreYVar2Node);
//	myPKB->linkNodes(expreMinus2Node,expreZVar2Node);
//
//	//build the AST for "z=(y-z)+x"
//	TreeNode* pattern3Node = myPKB->createTreeNode(AST_ASSIGN);
//	TreeNode* varRef3Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreYVar3Node = myPKB->createTreeNode(AST_VAR, yIndex);
//	TreeNode* expreZVar3Node = myPKB->createTreeNode(AST_VAR, zIndex);
//	TreeNode* expreXVar3Node = myPKB->createTreeNode(AST_VAR, xIndex);
//	TreeNode* expreMinus3Node = myPKB->createTreeNode(AST_MINUS);
//	TreeNode* exprePlus3Node = myPKB->createTreeNode(AST_PLUS);
//
//	myPKB->linkNodes(pattern3Node,varRef3Node);
//	myPKB->linkNodes(pattern3Node,exprePlus3Node);
//	myPKB->linkNodes(exprePlus3Node,expreMinus3Node);
//	myPKB->linkNodes(exprePlus3Node,expreXVarNode);
//	myPKB->linkNodes(expreMinus3Node,expreYVarNode);
//	myPKB->linkNodes(expreMinus3Node,expreZVarNode);
//
//	//insert to proc table, constantTable, lineTable, entity table and node table
//	Type::Index::Proc procIndex = myPKB->insertProc("TestAssign");
//	Type::Index::Proc procIndex2 = myPKB->insertProc("TestAssign2");
//	//x = x*(y-z)
//	myPKB->insertLine(1,procIndex,1);
//	myPKB->insertLineEntity(1,procIndex,1,ASSIGN);
//	myPKB->insertNode(1,procIndex,1,patternNode);
//	//x = y-z
//	myPKB->insertLine(2,procIndex,2);
//	myPKB->insertLineEntity(2,procIndex,2,ASSIGN);
//	myPKB->insertNode(2,procIndex,2,pattern2Node);
//	//z = (y-z)+x
//	myPKB->insertLine(3,procIndex2,1);
//	myPKB->insertLineEntity(3,procIndex2,1,ASSIGN);
//	myPKB->insertNode(3,procIndex2,1,pattern3Node);
//	
//	/*Type::List::Line realListOfMatchedLine;
//	realListOfMatchedLine.push_back(1);
//	realListOfMatchedLine.push_back(2);*/
//
//	Type::List::Stmt listOfMatchedStmt = myPKB->getStmtIndexForPattern(procIndex,PATTERN_ASSIGN,xIndex,NULL,true);
//	CPPUNIT_ASSERT_EQUAL(2,(int)listOfMatchedStmt.size());
//	CPPUNIT_ASSERT_EQUAL(1,listOfMatchedStmt.at(0));
//	CPPUNIT_ASSERT_EQUAL(2,listOfMatchedStmt.at(1));
//	//myPKB->~PKB();
//}